﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace SwiftMVVM.ChangeTracking
{
    /// <summary>
    /// Contains information about the property and object that changed
    /// </summary>
    internal sealed class PropertyChangeEventArgs : EventArgs
    {
        /// <summary>
        /// The object that changed
        /// </summary>
        public INotifyPropertyChanged SourceObject { get; private set; }

        /// <summary>
        /// The property on the object that changed
        /// </summary>
        public string PropertyName { get; private set; }

        /// <summary>
        /// The old value of the property (Only supported if the object supports INotifyPropertyChanging)
        /// </summary>
        public object OldValue { get; private set; }

        /// <summary>
        /// The new value of the property
        /// </summary>
        public object NewValue { get; private set; }

        /// <summary>
        /// Constructs a new instance of PropertyChangeEventArgs
        /// </summary>
        /// <param name="sourceObject">The object that changed</param>
        /// <param name="propertyName">The name of the property that changed</param>
        /// <param name="oldValue">The value prior to the change (Only if the object supports INotifyPropertyChanging)</param>
        /// <param name="newValue">The current value</param>
        public PropertyChangeEventArgs(INotifyPropertyChanged sourceObject, string propertyName, object oldValue, object newValue)
        {
            SourceObject = sourceObject;
            PropertyName = propertyName;
            OldValue = oldValue;
            NewValue = newValue;
        }
    }
}
